import os
import xml.etree.ElementTree
from contextlib import contextmanager
from io import BytesIO

from PIL import Image
import os
import pillow_avif
# from pillow_avif_demo import Image

try:
    from os import cpu_count
except ImportError:
    from multiprocessing import cpu_count

try:
    from unittest import mock
except ImportError:
    import mock


try:
    from PIL import UnidentifiedImageError
except ImportError:
    UnidentifiedImageError = None


CURR_DIR = os.path.dirname(os.path.dirname(__file__))
TEST_AVIF_FILE = "%s/tests/images/hopper.avif" % CURR_DIR

def test_exif(self):
    # With an EXIF chunk
    with Image.open("tests/images/exif.avif") as im:
        exif = im.getexif()
    assert exif[274] == 1


file_dir = '/Users/edgar/Desktop/0626'
for file in os.listdir(file_dir):
    if file.endswith('avif'):
        # with Image.open(os.path.join(file_dir, file)) as im:
        #     exif = im.getexif()

        print(file)
        avif_file = Image.open(os.path.join(file_dir, file))
        avif_file.save(file.replace('avif','png'),'PNG')

if __name__ == '__main__':
    pass
